package com.loser.cmd;

import com.loser.module.base.proto.sdk.user.UserInfoCmd;
import com.loser.module.base.proto.sdk.user.request.UserInfoReq;
import com.loser.module.base.proto.sdk.user.resp.UserInfoResult;
import com.loser.rpc.user.dto.resp.UserInfoResp;
import com.loser.user.mongo.handler.UserHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UserInfoCmdHandler implements UserInfoCmd {

    @Autowired
    private UserHandler userHandler;

    @Override
    public UserInfoResult getUserInfoCmd(UserInfoReq req) {

        UserInfoResp data = userHandler.getById(req.getUserId()).getData();
        UserInfoResult result = new UserInfoResult();
        result.setUserName(data.getLoginName());
        result.setUserId(data.getId());
        return result;

    }

}
